package cn.ymatrix.utils;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

public class Config {
  private static final Logger LOGGER = LoggerFactory.getLogger(Config.class);
  private static final String confFile = "/src/main/resources/conf.properties";

  private static final BasicDataSource dataSource = new BasicDataSource();

  // Oracle connect info
  private static String oracleURL = "";

  private static String oracleName = "";
  private static String oraclePassword = "";

  private static String oracleDriverName = "";
  private static String oracleQuery = "";

  // tencent soc info
  private static String secretId = "";
  private static String secretKey = "";
  private static String bucketName = "";
  private static String regionStr = "";
  private static String prefix = "";
  private static int fixedThreadPool = 0;

  private static String DRIVER_CLASS_NAME = "";

  private static String url = "";

  private static String userName = "";

  private static String passWord = "";

  private static String delimiter = "";

  private static String schemaName = "";

  private static String gRPCHost = "";

  private static int sdkConcurrency = 0;

  private static String linesOrBytesToFlush = "";

  private static int cacheEnqueueTimeout = 0;

  private static int requestTimeoutMillis = 0;
  private static int maxRequestQueued = 0;
  private static int maxRetryAttempts = 0;
  private static int retryWaitDurationMillis = 0;

  private static int enoughLinesOrBytes = 0;

  private static int intervalToFlushMillis = 0;

  private static int cacheCapacity = 0;
  private static String requestType = "";

  private static String asyncMode = "";

  private static String compressWithZstd = "";

  private static int csvConstructionBatchSize = 0;
  private static String dropAll = "";

  private static String tableName = "";

  private static String csvFilePath = "";

  private static String httpUrl = "";

  private static int initialSize = 0;

  private static String validationQuery = "";

  private static boolean testOnBorrow = true;

  private static int maxActive = 0;

  private static int maxWait = 0;

  private static int maxIdle = 0;

  private static int minIdle = 0;

  private static int timeBetweenEvictionRunsMillis = 0;

  private static int minEvictableIdleTimeMillis = 0;

  private static int numTestsPerEvictionRun = 0;

  private static boolean removeAbandoned = true;

  private static int removeAbandonedTimeout = 0;

  private static int totalNumber = 0;
  private static int batchSize = 0;

  private static String kafkaBootStrap = "";
  private static String kafkaTopic = "";
  private static String kafkaConsumerGroup = "";

  private static String offsetReset = "";

  private static int maxPollRecords = 0;

  private static int consumersSize = 0;
  private static int timeoutMillis = 0;

  private static String autoCommit = "";

  private static int maxPartitionFetchBytes = 0;

  private static String autoCommitIntervalMs = "";
  private static String sessionTimeoutMs = "";

  // eneryCar
  private static Long unixMsStartTime = 0L;
  private static Long unixMsEndTime = 0L;
  private static int pointStep = 0;
  private static int deviceNum = 0;
  private static String devicePathPrefix = "";
  private static int deviceStartNum = 0;
  private static int maximumPoolSize = 0;
  private static int maxConnPerRoute = 0;
  private static String eneryCarFile = "";

  // MQTT
  private static String mqttBroker = "";
  private static String mqttClientId = "";
  private static String mqttTopic = "";

  // RabbitMQ
  private static String queueName = "";
  private static String queueHost = "";
  private static String queueUserName = "";
  private static String queuePassword = "";

  private static boolean queueISexist = true;
  private static int queueThreadSleepTime = 0;

  public static String getOracleURL() {
    return oracleURL;
  }

  public static void setOracleURL(String oracleURL) {
    Config.oracleURL = oracleURL;
  }

  public static String getOracleName() {
    return oracleName;
  }

  public static void setOracleName(String oracleName) {
    Config.oracleName = oracleName;
  }

  public static String getOraclePassword() {
    return oraclePassword;
  }

  public static void setOraclePassword(String oraclePassword) {
    Config.oraclePassword = oraclePassword;
  }

  public static String getOracleDriverName() {
    return oracleDriverName;
  }

  public static void setOracleDriverName(String oracleDriverName) {
    Config.oracleDriverName = oracleDriverName;
  }

  public static String getOracleQuery() {
    return oracleQuery;
  }

  public static void setOracleQuery(String oracleQuery) {
    Config.oracleQuery = oracleQuery;
  }

  public static String getAutoCommit() {
    return autoCommit;
  }

  public static void setAutoCommit(String autoCommit) {
    Config.autoCommit = autoCommit;
  }

  public static String getSecretId() {
    return secretId;
  }

  public static void setSecretId(String secretId) {
    Config.secretId = secretId;
  }

  public static String getSecretKey() {
    return secretKey;
  }

  public static void setSecretKey(String secretKey) {
    Config.secretKey = secretKey;
  }

  public static String getBucketName() {
    return bucketName;
  }

  public static void setBucketName(String bucketName) {
    Config.bucketName = bucketName;
  }

  public static String getRegionStr() {
    return regionStr;
  }

  public static void setRegionStr(String regionStr) {
    Config.regionStr = regionStr;
  }

  public static String getPrefix() {
    return prefix;
  }

  public static void setPrefix(String prefix) {
    Config.prefix = prefix;
  }

  public static int getFixedThreadPool() {
    return fixedThreadPool;
  }

  public static void setFixedThreadPool(int fixedThreadPool) {
    Config.fixedThreadPool = fixedThreadPool;
  }

  public static String getDriverClassName() {
    return DRIVER_CLASS_NAME;
  }

  public static void setDriverClassName(String driverClassName) {
    DRIVER_CLASS_NAME = driverClassName;
  }

  public static String getDRIVER_CLASS_NAME() {
    return DRIVER_CLASS_NAME;
  }

  public static void setDRIVER_CLASS_NAME(String driver_class_name) {
    Config.DRIVER_CLASS_NAME = driver_class_name;
  }

  public static String getUrl() {
    return url;
  }

  public static void setUrl(String url) {
    Config.url = url;
  }

  public static String getUserName() {
    return userName;
  }

  public static void setUserName(String userName) {
    Config.userName = userName;
  }

  public static String getPassWord() {
    return passWord;
  }

  public static void setPassWord(String passWord) {
    Config.passWord = passWord;
  }

  public static String getDelimiter() {
    return delimiter;
  }

  public static void setDelimiter(String delimiter) {
    Config.delimiter = delimiter;
  }

  public static String getSchemaName() {
    return schemaName;
  }

  public static void setSchemaName(String schemaName) {
    Config.schemaName = schemaName;
  }

  public static String getgRPCHost() {
    return gRPCHost;
  }

  public static void setgRPCHost(String gRPCHost) {
    Config.gRPCHost = gRPCHost;
  }

  public static int getSdkConcurrency() {
    return sdkConcurrency;
  }

  public static void setSdkConcurrency(int sdkConcurrency) {
    Config.sdkConcurrency = sdkConcurrency;
  }

  public static String getLinesOrBytesToFlush() {
    return linesOrBytesToFlush;
  }

  public static void setLinesOrBytesToFlush(String linesOrBytesToFlush) {
    Config.linesOrBytesToFlush = linesOrBytesToFlush;
  }

  public static int getCacheEnqueueTimeout() {
    return cacheEnqueueTimeout;
  }

  public static void setCacheEnqueueTimeout(int cacheEnqueueTimeout) {
    Config.cacheEnqueueTimeout = cacheEnqueueTimeout;
  }

  public static int getRequestTimeoutMillis() {
    return requestTimeoutMillis;
  }

  public static void setRequestTimeoutMillis(int requestTimeoutMillis) {
    Config.requestTimeoutMillis = requestTimeoutMillis;
  }

  public static int getMaxRequestQueued() {
    return maxRequestQueued;
  }

  public static void setMaxRequestQueued(int maxRequestQueued) {
    Config.maxRequestQueued = maxRequestQueued;
  }

  public static int getMaxRetryAttempts() {
    return maxRetryAttempts;
  }

  public static void setMaxRetryAttempts(int maxRetryAttempts) {
    Config.maxRetryAttempts = maxRetryAttempts;
  }

  public static int getRetryWaitDurationMillis() {
    return retryWaitDurationMillis;
  }

  public static void setRetryWaitDurationMillis(int retryWaitDurationMillis) {
    Config.retryWaitDurationMillis = retryWaitDurationMillis;
  }

  public static void setOffsetReset(String offsetReset) {
    Config.offsetReset = offsetReset;
  }

  public static int getMaxPollRecords() {
    return maxPollRecords;
  }

  public static void setMaxPollRecords(int maxPollRecords) {
    Config.maxPollRecords = maxPollRecords;
  }

  public static int getEnoughLinesOrBytes() {
    return enoughLinesOrBytes;
  }

  public static void setEnoughLinesOrBytes(int enoughLinesOrBytes) {
    Config.enoughLinesOrBytes = enoughLinesOrBytes;
  }

  public static int getIntervalToFlushMillis() {
    return intervalToFlushMillis;
  }

  public static void setIntervalToFlushMillis(int intervalToFlushMillis) {
    Config.intervalToFlushMillis = intervalToFlushMillis;
  }

  public static int getCacheCapacity() {
    return cacheCapacity;
  }

  public static void setCacheCapacity(int cacheCapacity) {
    Config.cacheCapacity = cacheCapacity;
  }

  public static String getRequestType() {
    return requestType;
  }

  public static void setRequestType(String requestType) {
    Config.requestType = requestType;
  }

  public static String getAsyncMode() {
    return asyncMode;
  }

  public static void setAsyncMode(String asyncMode) {
    Config.asyncMode = asyncMode;
  }

  public static String getCompressWithZstd() {
    return compressWithZstd;
  }

  public static void setCompressWithZstd(String compressWithZstd) {
    Config.compressWithZstd = compressWithZstd;
  }

  public static int getCsvConstructionBatchSize() {
    return csvConstructionBatchSize;
  }

  public static void setCsvConstructionBatchSize(int csvConstructionBatchSize) {
    Config.csvConstructionBatchSize = csvConstructionBatchSize;
  }

  public static String getDropAll() {
    return dropAll;
  }

  public static void setDropAll(String dropAll) {
    Config.dropAll = dropAll;
  }

  public static String getTableName() {
    return tableName;
  }

  public static void setTableName(String tableName) {
    Config.tableName = tableName;
  }

  public static String getCsvFilePath() {
    return csvFilePath;
  }

  public static void setCsvFilePath(String csvFilePath) {
    Config.csvFilePath = csvFilePath;
  }

  public static String getHttpUrl() {
    return httpUrl;
  }

  public static void setHttpUrl(String httpUrl) {
    Config.httpUrl = httpUrl;
  }

  public static int getInitialSize() {
    return initialSize;
  }

  public static void setInitialSize(int initialSize) {
    Config.initialSize = initialSize;
  }

  public static String getValidationQuery() {
    return validationQuery;
  }

  public static void setValidationQuery(String validationQuery) {
    Config.validationQuery = validationQuery;
  }

  public static boolean isTestOnBorrow() {
    return testOnBorrow;
  }

  public static void setTestOnBorrow(boolean testOnBorrow) {
    Config.testOnBorrow = testOnBorrow;
  }

  public static int getMaxActive() {
    return maxActive;
  }

  public static void setMaxActive(int maxActive) {
    Config.maxActive = maxActive;
  }

  public static int getMaxWait() {
    return maxWait;
  }

  public static void setMaxWait(int maxWait) {
    Config.maxWait = maxWait;
  }

  public static int getMaxIdle() {
    return maxIdle;
  }

  public static void setMaxIdle(int maxIdle) {
    Config.maxIdle = maxIdle;
  }

  public static int getMinIdle() {
    return minIdle;
  }

  public static void setMinIdle(int minIdle) {
    Config.minIdle = minIdle;
  }

  public static int getTimeBetweenEvictionRunsMillis() {
    return timeBetweenEvictionRunsMillis;
  }

  public static void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) {
    Config.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
  }

  public static int getMinEvictableIdleTimeMillis() {
    return minEvictableIdleTimeMillis;
  }

  public static void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
    Config.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
  }

  public static int getNumTestsPerEvictionRun() {
    return numTestsPerEvictionRun;
  }

  public static void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
    Config.numTestsPerEvictionRun = numTestsPerEvictionRun;
  }

  public static String getAutoCommitIntervalMs() {
    return autoCommitIntervalMs;
  }

  public static void setAutoCommitIntervalMs(String autoCommitIntervalMs) {
    Config.autoCommitIntervalMs = autoCommitIntervalMs;
  }

  public static String getSessionTimeoutMs() {
    return sessionTimeoutMs;
  }

  public static void setSessionTimeoutMs(String sessionTimeoutMs) {
    Config.sessionTimeoutMs = sessionTimeoutMs;
  }

  public static boolean isRemoveAbandoned() {
    return removeAbandoned;
  }

  public static void setRemoveAbandoned(boolean removeAbandoned) {
    Config.removeAbandoned = removeAbandoned;
  }

  public static int getRemoveAbandonedTimeout() {
    return removeAbandonedTimeout;
  }

  public static void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
    Config.removeAbandonedTimeout = removeAbandonedTimeout;
  }

  public static int getTotalNumber() {
    return totalNumber;
  }

  public static void setTotalNumber(int totalNumber) {
    Config.totalNumber = totalNumber;
  }

  public static int getBatchSize() {
    return batchSize;
  }

  public static void setBatchSize(int batchSize) {
    Config.batchSize = batchSize;
  }

  public static String getKafkaBootStrap() {
    return kafkaBootStrap;
  }

  public static void setKafkaBootStrap(String kafkaBootStrap) {
    Config.kafkaBootStrap = kafkaBootStrap;
  }

  public static String getKafkaTopic() {
    return kafkaTopic;
  }

  public static void setKafkaTopic(String kafkaTopic) {
    Config.kafkaTopic = kafkaTopic;
  }

  public static String getKafkaConsumerGroup() {
    return kafkaConsumerGroup;
  }

  public static void setKafkaConsumerGroup(String kafkaConsumerGroup) {
    Config.kafkaConsumerGroup = kafkaConsumerGroup;
  }

  public static int getConsumersSize() {
    return consumersSize;
  }

  public static void setConsumersSize(int consumersSize) {
    Config.consumersSize = consumersSize;
  }

  public static int getTimeoutMillis() {
    return timeoutMillis;
  }

  public static void setTimeoutMillis(int timeoutMillis) {
    Config.timeoutMillis = timeoutMillis;
  }

  public static String getOffsetReset() {
    return offsetReset;
  }

  public static int getMaxPartitionFetchBytes() {
    return maxPartitionFetchBytes;
  }

  public static void setMaxPartitionFetchBytes(int maxPartitionFetchBytes) {
    Config.maxPartitionFetchBytes = maxPartitionFetchBytes;
  }

  public static void setOffsetResetString(String offsetReset) {
    Config.offsetReset = offsetReset;
  }

  public static Long getUnixMsStartTime() {
    return unixMsStartTime;
  }

  public static void setUnixMsStartTime(Long unixMsStartTime) {
    Config.unixMsStartTime = unixMsStartTime;
  }

  public static Long getUnixMsEndTime() {
    return unixMsEndTime;
  }

  public static void setUnixMsEndTime(Long unixMsEndTime) {
    Config.unixMsEndTime = unixMsEndTime;
  }

  public static int getPointStep() {
    return pointStep;
  }

  public static void setPointStep(int pointStep) {
    Config.pointStep = pointStep;
  }

  public static int getDeviceNum() {
    return deviceNum;
  }

  public static void setDeviceNum(int deviceNum) {
    Config.deviceNum = deviceNum;
  }

  public static String getDevicePathPrefix() {
    return devicePathPrefix;
  }

  public static void setDevicePathPrefix(String devicePathPrefix) {
    Config.devicePathPrefix = devicePathPrefix;
  }

  public static int getDeviceStartNum() {
    return deviceStartNum;
  }

  public static void setDeviceStartNum(int deviceStartNum) {
    Config.deviceStartNum = deviceStartNum;
  }

  public static int getMaximumPoolSize() {
    return maximumPoolSize;
  }

  public static void setMaximumPoolSize(int maximumPoolSize) {
    Config.maximumPoolSize = maximumPoolSize;
  }

  public static String getEneryCarFile() {
    return eneryCarFile;
  }

  public static void setEneryCarFile(String eneryCarFile) {
    Config.eneryCarFile = eneryCarFile;
  }

  public static int getMaxConnPerRoute() {
    return maxConnPerRoute;
  }

  public static void setMaxConnPerRoute(int maxConnPerRoute) {
    Config.maxConnPerRoute = maxConnPerRoute;
  }

  public static String getMqttBroker() {
    return mqttBroker;
  }

  public static void setMqttBroker(String mqttBroker) {
    Config.mqttBroker = mqttBroker;
  }

  public static String getMqttClientId() {
    return mqttClientId;
  }

  public static void setMqttClientId(String mqttClientId) {
    Config.mqttClientId = mqttClientId;
  }

  public static String getMqttTopic() {
    return mqttTopic;
  }

  public static void setMqttTopic(String mqttTopic) {
    Config.mqttTopic = mqttTopic;
  }

  public static String getQueueName() {
    return queueName;
  }

  public static void setQueueName(String queueName) {
    Config.queueName = queueName;
  }

  public static String getQueueHost() {
    return queueHost;
  }

  public static void setQueueHost(String queueHost) {
    Config.queueHost = queueHost;
  }

  public static String getQueueUserName() {
    return queueUserName;
  }

  public static void setQueueUserName(String queueUserName) {
    Config.queueUserName = queueUserName;
  }

  public static String getQueuePassword() {
    return queuePassword;
  }

  public static void setQueuePassword(String queuePassword) {
    Config.queuePassword = queuePassword;
  }

  public static boolean isQueueISexist() {
    return queueISexist;
  }

  public static void setQueueISexist(boolean queueISexist) {
    Config.queueISexist = queueISexist;
  }

  public static int getQueueThreadSleepTime() {
    return queueThreadSleepTime;
  }

  public static void setQueueThreadSleepTime(int queueThreadSleepTime) {
    Config.queueThreadSleepTime = queueThreadSleepTime;
  }

  static {
    try {
      Properties properties = new Properties();
      BufferedReader bufferedReader =
          new BufferedReader(new FileReader(System.getProperty("user.dir") + confFile));
      properties.load(bufferedReader);
      // Oracle connect info
      setOracleURL(properties.getProperty("oracleURL"));
      setOracleDriverName(properties.getProperty("oracleDriverName"));
      setOracleName(properties.getProperty("oracleName"));
      setOraclePassword(properties.getProperty("oraclePassword"));
      setOracleQuery(properties.getProperty("oracleQuery"));

      // 以下是JDBC配置
      setDRIVER_CLASS_NAME(properties.getProperty("DRIVER_CLASS_NAME"));
      setUrl(properties.getProperty("URL"));
      setUserName(properties.getProperty("UserName"));
      setPassWord(properties.getProperty("PassWord"));
      setDelimiter(properties.getProperty("Delimiter"));
      setTableName(properties.getProperty("TableName"));
      setTotalNumber(Integer.parseInt(properties.getProperty("TotalNumber")));
      setBatchSize(Integer.parseInt(properties.getProperty("BatchSize")));
      setCsvFilePath(properties.getProperty("csvFilePath"));

      // tencent soc info
      setSecretId(properties.getProperty("secretId"));
      setSecretKey(properties.getProperty("secretKey"));
      setBucketName(properties.getProperty("bucketName"));
      setRegionStr(properties.getProperty("regionStr"));
      setPrefix(properties.getProperty("prefix"));
      setFixedThreadPool(Integer.parseInt(properties.getProperty("fixedThreadPool")));

      // httpClient 配置
      setHttpUrl(properties.getProperty("httpUrl"));
      setSchemaName(properties.getProperty("schemaName"));

      // Mxgate-SDK 连接配置
      setgRPCHost(properties.getProperty("gRPCHost"));
      setSdkConcurrency(Integer.parseInt(properties.getProperty("sdkConcurrency")));
      setCacheEnqueueTimeout(Integer.parseInt(properties.getProperty("cacheEnqueueTimeout")));
      setRequestTimeoutMillis(Integer.parseInt(properties.getProperty("requestTimeoutMillis")));
      setMaxRequestQueued(Integer.parseInt(properties.getProperty("maxRequestQueued")));
      setMaxRetryAttempts(Integer.parseInt(properties.getProperty("maxRetryAttempts")));
      setRetryWaitDurationMillis(
          Integer.parseInt(properties.getProperty("retryWaitDurationMillis")));
      setLinesOrBytesToFlush(properties.getProperty("linesOrBytesToFlush"));
      setEnoughLinesOrBytes(Integer.parseInt(properties.getProperty("enoughLinesOrBytes")));
      setIntervalToFlushMillis(Integer.parseInt(properties.getProperty("intervalToFlushMillis")));
      setCacheCapacity(Integer.parseInt(properties.getProperty("cacheCapacity")));
      setRequestType(properties.getProperty("requestType"));
      setAsyncMode(properties.getProperty("asyncMode"));
      setCompressWithZstd(properties.getProperty("compressWithZstd"));
      setCsvConstructionBatchSize(
          Integer.parseInt(properties.getProperty("csvConstructionBatchSize")));
      setDropAll(properties.getProperty("dropAll"));

      // kafka 连接信息
      setKafkaBootStrap(properties.getProperty("kafkaBootStrap"));
      setKafkaTopic(properties.getProperty("kafkaTopic"));
      setKafkaConsumerGroup(properties.getProperty("kafkaConsumerGroup"));
      setConsumersSize(Integer.parseInt(properties.getProperty("consumersSize")));
      setTimeoutMillis(Integer.parseInt(properties.getProperty("timeoutMillis")));
      setOffsetResetString(properties.getProperty("offsetReset"));
      setMaxPollRecords(Integer.parseInt(properties.getProperty("maxPollRecords")));
      setAutoCommit(properties.getProperty("autoCommit"));
      setMaxPartitionFetchBytes(Integer.parseInt(properties.getProperty("maxPartitionFetchBytes")));
      setAutoCommitIntervalMs(properties.getProperty("autoCommitIntervalMs"));
      setSessionTimeoutMs(properties.getProperty("sessionTimeoutMs"));

      // 以下为DBCP连接池的配置
      dataSource.setDriverClassName(properties.getProperty("DRIVER_CLASS_NAME"));
      dataSource.setUrl(properties.getProperty("URL"));
      dataSource.setUsername(properties.getProperty("UserName"));
      dataSource.setPassword(properties.getProperty("PassWord"));
      dataSource.setInitialSize(Integer.parseInt(properties.getProperty("InitialSize")));
      dataSource.setValidationQuery(properties.getProperty("ValidationQuery"));
      dataSource.setTestOnBorrow(Boolean.parseBoolean(properties.getProperty("TestOnBorrow")));
      dataSource.setMaxActive(Integer.parseInt(properties.getProperty("MaxActive")));
      dataSource.setMaxWait(Integer.parseInt(properties.getProperty("MaxWait")));
      dataSource.setMaxIdle(Integer.parseInt(properties.getProperty("MaxIdle")));
      dataSource.setMinIdle(Integer.parseInt(properties.getProperty("MinIdle")));
      dataSource.setTimeBetweenEvictionRunsMillis(
          Integer.parseInt(properties.getProperty("timeBetweenEvictionRunsMillis")));
      dataSource.setMinEvictableIdleTimeMillis(
          Integer.parseInt(properties.getProperty("minEvictableIdleTimeMillis")));
      dataSource.setNumTestsPerEvictionRun(
          Integer.parseInt(properties.getProperty("numTestsPerEvictionRun")));
      dataSource.setRemoveAbandoned(
          Boolean.parseBoolean(properties.getProperty("removeAbandoned")));
      dataSource.setRemoveAbandonedTimeout(
          Integer.parseInt(properties.getProperty("removeAbandonedTimeout")));

      // eneryCar
      setUnixMsStartTime(Long.parseLong(properties.getProperty("unixMsStartTime")));
      setUnixMsEndTime(Long.parseLong(properties.getProperty("unixMsEndTime")));
      setPointStep(Integer.parseInt(properties.getProperty("pointStep")));
      setDeviceNum(Integer.parseInt(properties.getProperty("deviceNum")));
      setDevicePathPrefix(properties.getProperty("devicePathPrefix"));
      setDeviceStartNum(Integer.parseInt(properties.getProperty("deviceStartNum")));
      setMaximumPoolSize(Integer.parseInt(properties.getProperty("maximumPoolSize")));
      setMaxConnPerRoute(Integer.parseInt(properties.getProperty("maxConnPerRoute")));
      setEneryCarFile(properties.getProperty("measurementFile"));

      // MQTT 连接参数
      setMqttBroker(properties.getProperty("mqttBroker"));
      setMqttClientId(properties.getProperty("mqttClientId"));
      setMqttTopic(properties.getProperty("mqttTopic"));

      // RabbitMQ 连接参数
      setQueueName(properties.getProperty("queueName"));
      setQueueHost(properties.getProperty("queueHost"));
      setQueueUserName(properties.getProperty("queueUserName"));
      setQueuePassword(properties.getProperty("queuePassword"));
      setQueueISexist(Boolean.parseBoolean(properties.getProperty("queueISexist")));
      setQueueThreadSleepTime(Integer.parseInt(properties.getProperty("queueThreadSleepTime")));

    } catch (IOException e) {
      LOGGER.error("DataSource init error: {}", e.getMessage());
    }
  }

  // 提供获得数据源
  public static DataSource getDateSource() {
    return dataSource;
  }

  // 提供获得链接
  public static Connection getConnection() throws SQLException {
    return dataSource.getConnection();
  }
}
